package com.servengine.localizame;

import com.servengine.user.User;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;

@Entity
@NamedQueries ({
	@NamedQuery(name = "LocalizamePosicion.findByCodigoPostalAndDateExceptUser", query = "select o from LocalizamePosicion o where o.codigoPostal = :codigoPostal and o.date > :date and not o.user = :user"),
	@NamedQuery(name = "LocalizamePosicion.findByUser", query = "select o from LocalizamePosicion o where o.user = :user")
})
public class LocalizamePosicion
{
	Integer id;
	User user;
	Date date;
	String codigoPostal;
	
	public LocalizamePosicion()
	{
	}

	public LocalizamePosicion(User user, String codigoPostal)
	{
		date=new java.util.Date();
		this.user=user;
		this.codigoPostal=codigoPostal;
	}

	public void setId(Integer id)
	{
		this.id = id;
	}

	@Id @GeneratedValue
	public Integer getId()
	{
		return id;
	}

	public void setUser(User user)
	{
		this.user = user;
	}

	@OneToOne
	public User getUser()
	{
		return user;
	}

	public void setDate(Date date)
	{
		this.date = date;
	}

	public Date getDate()
	{
		return date;
	}

	public void setCodigoPostal(String codigoPostal)
	{
		this.codigoPostal = codigoPostal;
	}

	public String getCodigoPostal()
	{
		return codigoPostal;
	}
}
